package com.kotlin.demo.类


sealed class Students {

    object Student1 : Students()
    object Student2 : Students()
    object Student3 : Students()
    class Student4(val name: String) : Students()
    class Student5(val age: String) : Students()

}

class Teacher(private val student: Students) {

    fun show(): String =
        when (student) {
            is Students.Student1 -> this.javaClass.toString()
            is Students.Student2 -> this.javaClass.toString()
            is Students.Student3 -> this.javaClass.toString()
            is Students.Student4 -> "${this.javaClass} name:${this.student.name}"
            is Students.Student5 -> "${this.javaClass} age:${this.student.age}"
        }

}

fun main() {
    println(Teacher(Students.Student4("zq")).show())
    println((Students.Student2 === Students.Student2)) //这个是object 修饰 是单例
    println((Students.Student4("zq") === Students.Student4("zq"))) //这个是Class修饰,不是单例



}